import { getFingerApi, getUserLikeApi } from "../api/user";
export default {
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      page: 1,
      isErr: false,
    };
  },
  methods: {
    async getList(val, page = this.page) {
      try {
        const {
          data: {
            list: { count, data },
          },
        } = await getUserLikeApi({ type: val, page, limit: 10 });
        // console.log(list);
        this.list.push(...data);
        this.list.length >= count ? (this.finished = true) : this.page++;
      } catch (err) {
        this.isErr = true;
      } finally {
        this.loading = false;
      }
    },
    async finger(type, id) {
      const { data } = await getFingerApi({
        type,
        article_id: id,
        action: "del",
      });
      // console.log(res);
      this.$toast(data)
      this.list = []
      this.getList(type, 1)
    },
  },
}